from toee import *
from utilities import *

def san_dialog( attachee, triggerer ):
	if (game.global_flags[61] == 1):
		triggerer.begin_dialog( attachee, 500 )
	elif (attachee.leader_get() != OBJ_HANDLE_NULL):
		triggerer.begin_dialog( attachee, 300 )
	elif (game.global_flags[51] == 1):
		if (game.quests[18].state == qs_completed):
			triggerer.begin_dialog( attachee, 220 )
		else:
			triggerer.begin_dialog( attachee, 210 )
	else:
		triggerer.begin_dialog( attachee, 1 )
	return SKIP_DEFAULT

def san_dying( attachee, triggerer ):
	game.global_flags[58] = 1
	game.global_vars[29] = game.global_vars[29] + 1
	attachee.float_line(12014,triggerer)
	if (attachee.leader_get() == OBJ_HANDLE_NULL):
		game.global_vars[23] = game.global_vars[23] + 1
		if (game.global_vars[23] >= 2):
			game.party[0].reputation_add( 1 )
	else:
		game.global_vars[29] = game.global_vars[29] + 1
	return RUN_DEFAULT

def san_resurrect( attachee, triggerer ):
	game.global_flags[58] = 0
	return RUN_DEFAULT

def san_new_map( attachee, triggerer ):
	if ((attachee.area == 2) or (attachee.area == 4)):
		game.global_flags[60] = 1
	elif ((attachee.area == 1) and (game.global_flags[60] == 1)):
		game.global_flags[60] = 0
		if (attachee.money_get() >= 200000):
			leader = attachee.leader_get()
			if (leader != OBJ_HANDLE_NULL):
				leader.begin_dialog(attachee, 400)
	return RUN_DEFAULT

def equip_transfer( attachee, triggerer ):
	itemA = attachee.item_find(6011)
	if (itemA != OBJ_HANDLE_NULL):
		itemA.destroy()
		create_item_in_inventory( 6011, triggerer )
	itemB = attachee.item_find(6012)
	if (itemB != OBJ_HANDLE_NULL):
		itemB.destroy()
		create_item_in_inventory( 6012, triggerer )
	itemC = attachee.item_find(6013)
	if (itemC != OBJ_HANDLE_NULL):
		itemC.destroy()
		create_item_in_inventory( 6013, triggerer )
	itemD = attachee.item_find(4049)
	if (itemD != OBJ_HANDLE_NULL):
		itemD.destroy()
		create_item_in_inventory( 4049, triggerer )
	create_item_in_inventory( 7001, attachee )
	create_item_in_inventory( 7001, attachee )
	create_item_in_inventory( 7001, attachee )
	create_item_in_inventory( 7001, attachee )
	create_item_in_inventory( 7001, attachee )
	return RUN_DEFAULT

